package org.htmlparser.visitors;

import org.htmlparser.Parser;
import org.htmlparser.Tag;
import org.htmlparser.tags.BodyTag;
import org.htmlparser.tags.TableTag;
import org.htmlparser.tags.TitleTag;
import org.htmlparser.util.NodeList;

public class HtmlPage extends NodeVisitor
{
  private NodeList nodesInBody;
  private NodeList tables;
  private String title = "";

  public HtmlPage(Parser paramParser)
  {
    super(true);
    this.nodesInBody = new NodeList();
    this.tables = new NodeList();
  }

  private boolean isBodyTag(Tag paramTag)
  {
    return paramTag instanceof BodyTag;
  }

  private boolean isTable(Tag paramTag)
  {
    return paramTag instanceof TableTag;
  }

  private boolean isTitleTag(Tag paramTag)
  {
    return paramTag instanceof TitleTag;
  }

  public NodeList getBody()
  {
    return this.nodesInBody;
  }

  public TableTag[] getTables()
  {
    TableTag[] arrayOfTableTag = new TableTag[this.tables.size()];
    this.tables.copyToNodeArray(arrayOfTableTag);
    return arrayOfTableTag;
  }

  public String getTitle()
  {
    return this.title;
  }

  public void setTitle(String paramString)
  {
    this.title = paramString;
  }

  public void visitTag(Tag paramTag)
  {
    if (isTable(paramTag))
      this.tables.add(paramTag);
    while (true)
    {
      do
        while (true)
        {
          return;
          if (!(isBodyTag(paramTag)))
            break;
          this.nodesInBody = paramTag.getChildren();
        }
      while (!(isTitleTag(paramTag)));
      this.title = ((TitleTag)paramTag).getTitle();
    }
  }
}